package tx.bjdacp.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.junit.Test;

import cn.org.rapid_framework.test.context.TestMethodContext;
import static junit.framework.Assert.*;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bjdacp.model.*;
import tx.bjdacp.dao.*;
import tx.bjdacp.service.*;
import tx.bjdacp.vo.query.*;


public class DrugSellUnitManagerTest extends BaseManagerTestCase{

	private DrugSellUnitManager manager;

	@Autowired
	public void setDrugSellUnitManager(DrugSellUnitManager manager) {
		this.manager = manager;
	}

    @Override
    protected String[] getDbUnitDataFiles() {
        //通过 TestMethodContext.getMethodName() 可以得到当前正在运行的测试方法名称
        return new String[]{"classpath:testdata/common.xml","classpath:testdata/DrugSellUnit.xml",
                            "classpath:testdata/DrugSellUnit_"+TestMethodContext.getMethodName()+".xml"};
    }

	//数据库单元测试前会开始事务，结束时会回滚事务，所以测试方法可以不用关心测试数据的删除
	@Test
	public void crud() {

		DrugSellUnit obj = newDrugSellUnit();
		manager.save(obj);
		manager.getEntityDao().flush();

		manager.update(obj);
		manager.getEntityDao().flush();

		assertNotNull(obj.getDrugSellUnitId());

		manager.removeById(obj.getDrugSellUnitId());
		manager.getEntityDao().flush();

	}

	public static DrugSellUnit newDrugSellUnit() {
		DrugSellUnit obj = new DrugSellUnit();

	  	obj.setDrugSellUnitPrepareId(new java.lang.Integer("1"));
	  	obj.setZoneId(new java.lang.Integer("1"));
	  	obj.setUnitName(new java.lang.String("1"));
	  	obj.setRegistAddress(new java.lang.String("1"));
	  	obj.setArtificialPerson(new java.lang.String("1"));
	  	obj.setUnitPrincipal(new java.lang.String("1"));
	  	obj.setQualityPrincipal(new java.lang.String("1"));
	  	obj.setApothecary(new java.lang.String("1"));
	  	obj.setSellMode(new java.lang.String("1"));
	  	obj.setSellArea(new java.lang.String("1"));
	  	obj.setStorageAddress(new java.lang.String("1"));
	  	obj.setLicenceCode(new java.lang.String("1"));
	  	obj.setUnitFoundDate(new java.util.Date(System.currentTimeMillis()));
	  	obj.setLicenceGiveDate(new java.util.Date(System.currentTimeMillis()));
	  	obj.setLicenceExpiryDate(new java.util.Date(System.currentTimeMillis()));
	  	obj.setGspCode(new java.lang.String("1"));
	  	obj.setGspGiveDate(new java.util.Date(System.currentTimeMillis()));
	  	obj.setGspExpiryDate(new java.util.Date(System.currentTimeMillis()));
	  	obj.setIsLogout(new java.lang.String("1"));
	  	obj.setLogoutDate(new java.lang.String("1"));
	  	obj.setMobelPhone(new java.lang.String("1"));
	  	obj.setPhone(new java.lang.String("1"));
	  	obj.setIsTourDrugstore(new java.lang.Integer("1"));
	  	obj.setIsSellChineseMedicine(new java.lang.Integer("1"));
	  	obj.setIsOtcunit(new java.lang.Integer("1"));
	  	obj.setIsResendLicense(new java.lang.Integer("1"));
		return obj;
	}
}
